/**
 * <copyright>
 * </copyright>
 *
 */
package org.soaism.soadsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.soaism.soadsl.ApplicationInfo;
import org.soaism.soadsl.ImportInfo;
import org.soaism.soadsl.Model;
import org.soaism.soadsl.ModelAspect;
import org.soaism.soadsl.SoadslPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.soaism.soadsl.impl.ModelImpl#getImportInfo <em>Import Info</em>}</li>
 *   <li>{@link org.soaism.soadsl.impl.ModelImpl#getApplicationInfo <em>Application Info</em>}</li>
 *   <li>{@link org.soaism.soadsl.impl.ModelImpl#getModelaspects <em>Modelaspects</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ModelImpl extends MinimalEObjectImpl.Container implements Model
{
  /**
   * The cached value of the '{@link #getImportInfo() <em>Import Info</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getImportInfo()
   * @generated
   * @ordered
   */
  protected ImportInfo importInfo;

  /**
   * The cached value of the '{@link #getApplicationInfo() <em>Application Info</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getApplicationInfo()
   * @generated
   * @ordered
   */
  protected ApplicationInfo applicationInfo;

  /**
   * The cached value of the '{@link #getModelaspects() <em>Modelaspects</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getModelaspects()
   * @generated
   * @ordered
   */
  protected EList<ModelAspect> modelaspects;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ModelImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SoadslPackage.Literals.MODEL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ImportInfo getImportInfo()
  {
    return importInfo;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetImportInfo(ImportInfo newImportInfo, NotificationChain msgs)
  {
    ImportInfo oldImportInfo = importInfo;
    importInfo = newImportInfo;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SoadslPackage.MODEL__IMPORT_INFO, oldImportInfo, newImportInfo);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setImportInfo(ImportInfo newImportInfo)
  {
    if (newImportInfo != importInfo)
    {
      NotificationChain msgs = null;
      if (importInfo != null)
        msgs = ((InternalEObject)importInfo).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SoadslPackage.MODEL__IMPORT_INFO, null, msgs);
      if (newImportInfo != null)
        msgs = ((InternalEObject)newImportInfo).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SoadslPackage.MODEL__IMPORT_INFO, null, msgs);
      msgs = basicSetImportInfo(newImportInfo, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SoadslPackage.MODEL__IMPORT_INFO, newImportInfo, newImportInfo));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ApplicationInfo getApplicationInfo()
  {
    return applicationInfo;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetApplicationInfo(ApplicationInfo newApplicationInfo, NotificationChain msgs)
  {
    ApplicationInfo oldApplicationInfo = applicationInfo;
    applicationInfo = newApplicationInfo;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SoadslPackage.MODEL__APPLICATION_INFO, oldApplicationInfo, newApplicationInfo);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setApplicationInfo(ApplicationInfo newApplicationInfo)
  {
    if (newApplicationInfo != applicationInfo)
    {
      NotificationChain msgs = null;
      if (applicationInfo != null)
        msgs = ((InternalEObject)applicationInfo).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SoadslPackage.MODEL__APPLICATION_INFO, null, msgs);
      if (newApplicationInfo != null)
        msgs = ((InternalEObject)newApplicationInfo).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SoadslPackage.MODEL__APPLICATION_INFO, null, msgs);
      msgs = basicSetApplicationInfo(newApplicationInfo, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SoadslPackage.MODEL__APPLICATION_INFO, newApplicationInfo, newApplicationInfo));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ModelAspect> getModelaspects()
  {
    if (modelaspects == null)
    {
      modelaspects = new EObjectContainmentEList<ModelAspect>(ModelAspect.class, this, SoadslPackage.MODEL__MODELASPECTS);
    }
    return modelaspects;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SoadslPackage.MODEL__IMPORT_INFO:
        return basicSetImportInfo(null, msgs);
      case SoadslPackage.MODEL__APPLICATION_INFO:
        return basicSetApplicationInfo(null, msgs);
      case SoadslPackage.MODEL__MODELASPECTS:
        return ((InternalEList<?>)getModelaspects()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SoadslPackage.MODEL__IMPORT_INFO:
        return getImportInfo();
      case SoadslPackage.MODEL__APPLICATION_INFO:
        return getApplicationInfo();
      case SoadslPackage.MODEL__MODELASPECTS:
        return getModelaspects();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SoadslPackage.MODEL__IMPORT_INFO:
        setImportInfo((ImportInfo)newValue);
        return;
      case SoadslPackage.MODEL__APPLICATION_INFO:
        setApplicationInfo((ApplicationInfo)newValue);
        return;
      case SoadslPackage.MODEL__MODELASPECTS:
        getModelaspects().clear();
        getModelaspects().addAll((Collection<? extends ModelAspect>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SoadslPackage.MODEL__IMPORT_INFO:
        setImportInfo((ImportInfo)null);
        return;
      case SoadslPackage.MODEL__APPLICATION_INFO:
        setApplicationInfo((ApplicationInfo)null);
        return;
      case SoadslPackage.MODEL__MODELASPECTS:
        getModelaspects().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SoadslPackage.MODEL__IMPORT_INFO:
        return importInfo != null;
      case SoadslPackage.MODEL__APPLICATION_INFO:
        return applicationInfo != null;
      case SoadslPackage.MODEL__MODELASPECTS:
        return modelaspects != null && !modelaspects.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //ModelImpl
